<? $form = new Form(); ?>

<? if(!empty($errors)){?>
   <div id="register_form_error_messages">
   <? foreach($errors as $error => $text){?>
    <div><?= $text ?></div>
   <? } ?>
   </div>
<? }?>

<?= $form->open('user/register') ?>
<fieldset id="register_fieldset">
<legend>Register form</legend>
<?= $form->input('token_form', Security::token(), array('type' => 'hidden')) ?>

<?= $form->label('username'); ?>
<?= $form->input('username', $post['username'], array('type' => 'text', 'maxlength' => 50, 'autocomplete' => 'off')); ?>

<?= $form->label('email'); ?>
<?= $form->input('email', $post['email'], array('type' => 'text', 'maxlength' => 80, 'size' => 30, 'autocomplete' => 'off')); ?>

<?= $form->label('name'); ?>
<?= $form->input('name', $post['name'], array('type' => 'text', 'maxlength' => 50, 'autocomplete' => 'off')); ?>

<?= $form->label('lastname'); ?>
<?= $form->input('lastname', $post['lastname'], array('type' => 'text', 'maxlength' => 50, 'autocomplete' => 'off')); ?>

<?  $sex = array('Selecciona el sexo', 'Mujer', 'Hombre'); ?>
<?= $form->select('sex', $sex, $post['sex'], array('id' => 'sex')); ?>

<?= $form->label('birthdate'); ?>
<?  
    $days['-1'] = 'Día';
    $days += Date::days(1, date("Y"));
    
    $months['-1'] = 'Mes';
    $months += Date::months();
    
    $years['-1'] = 'Año';
    $aux_years = array_reverse(Date::years(date("Y") - 100, date("Y")));

    foreach($aux_years as $aux_year){
      $years[$aux_year] = $aux_year;
    }
?>

<?= $form->select('birthdate_day', $days, $post['birthdate_day'], array('id' => 'birthdate_day', 'autocomplete' => 'off')); ?>
<?= $form->select('birthdate_month', $months, $post['birthdate_month'], array('id' => 'birthdate_month', 'autocomplete' => 'off')); ?>
<?= $form->select('birthdate_year', $years, $post['birthdate_year'], array('id' => 'birthdate_year', 'autocomplete' => 'off')); ?>

<?= $form->label('password'); ?>
<?= $form->input('password', $post['password'], array('type' => 'password', 'maxlength' => 50, 'autocomplete' => 'off')); ?>

<?= $form->label('password_confirmation'); ?>
<?= $form->input('password_confirmation', $post['password_confirmation'], array('type' => 'password', 'maxlength' => 50, 'autocomplete' => 'off')); ?>

<?= $form->submit('register', 'Register') ?>
</fieldset>
<?= $form->close(); ?>